package com.asus.sun.extend.nodeAttr;

import org.flowable.editor.language.json.converter.CustomPropertyInit;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by Lenovo on 2019/8/12.
 */
@Configuration
public class ExtendFlowableConfig implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {
    private static final Logger LOGGER = LoggerFactory.getLogger(ExtendFlowableConfig.class);
    @Override
    public void configure(SpringProcessEngineConfiguration configure) {
        //配置中文
//        configure.setActivityFontName(activityFontName);
//        configure.setLabelFontName(labelFontName);
//        configure.setAnnotationFontName(annotationFontName);
        configure.setActivityFontName("宋体");
        configure.setLabelFontName("宋体");
        configure.setAnnotationFontName("宋体");
//        //设置自定义的uuid生成策略
//        configure.setIdGenerator(new UuidGenerator());
//        configure.setXmlEncoding(xmlEncoding);
//        //全局监听
//        Map<String, List<FlowableEventListener>> typedListeners = this.createGlobEventListeners();
//        configure.setTypedEventListeners(typedListeners);
//        //启用任务关系计数
//        configure.setEnableTaskRelationshipCounts(true);
//
//        /**
//         * 兼容V5
//         */
//        configure.setDatabaseSchemaUpdate("true");
//        configure.setFlowable5CompatibilityEnabled(true);
//        configure.setFlowable5CompatibilityHandlerFactory(createSpringFlowable5CompatibilityHandlerFactory());

        /**
         * 自定义节点属性初始化
         */
        createCustomPropertyInit().init();
    }

    @Bean
    public CustomPropertyInit createCustomPropertyInit() {
        CustomPropertyInit customPropertyInit = new CustomPropertyInit();
        LOGGER.info("==ExtendFlowableConfig==初始化自定义的任务json转化器=====");
        return customPropertyInit;
    }
}
